<?php


namespace app\admin\model\xilumarket\order;

use think\Model;
use app\common\model\xilumarket\Area;
use app\common\model\xilumarket\Product;

class OrderAddress extends Model
{
    protected $name = 'xilumarket_order_address';


    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    protected $append = [
        'Area'
    ];

    public function getAreaAttr($value,$data){
        return [
            'province' => !empty($data['province_id']) ? Area::getNameById($data['province_id']) : '',
            'city' => !empty($data['city_id']) ? Area::getNameById($data['city_id']) : '',
            'region' => !empty($data['region_id']) ? Area::getNameById($data['region_id']) : '',
        ];
    }
}